<template>
  <el-drawer
    title="添加 / 编辑"
    size="50%"
    :visible.sync="visible">
    <template slot="title">
      <span class="title">添加 / 编辑</span>
      <div class="btn-wrap">
        <el-button size="small" @click="close">关闭</el-button>
        <el-button type="primary" size="small" @click="save">保存</el-button>
      </div>
    </template>
    <div class="modify common-container">
      <div class="common-bot">
        <div class="modify-bot">
          <el-form ref="form" :model="form" label-width="80px">
            <el-form-item required label="反馈内容">
              <el-input v-model="form.content" type="textarea" :autosize="{minRows:10}" placeholder="请输入您要反馈的内容"></el-input>
            </el-form-item>
          </el-form>
        </div>
      </div>
    </div>
  </el-drawer>
</template>
<script>
  import Api from "@/api/";

  export default {
    data() {
      return {
        visible: false,
        form: {},
      };
    },
    methods: {
      show(id) {
        this.visible = true
        if (id) this.getInfo(id)
        else this.resetForm()
      },
      close() {
        this.visible = false
        this.$emit('close')
      },
      resetForm() {
        this.form = {
          formId: 0,
          content: "",
        };
      },
      getInfo(id) {
        Api.sysFeedback.detail({
          targetId: id,
        }).then((res) => {
          this.form = res.data
          this.form.formId = res.data.id
        });
      },
      save() {
        Api.sysFeedback.modify(this.form).then((res) => {
          if (res.code == 200) {
            this.$message.success("操作成功");
            this.close()
          }
        });
      },
    },
  };
</script>
<style scoped lang="scss">
  .modify {
    .modify-bot {
      width: 100%;
      padding: 30px 10px;
    }
  }
</style>
